{% extends 'extras/report/base.html' %}
{% load helpers %}
{% load form_helpers %}
{% load i18n %}

{% block content %}
  <div role="tabpanel" class="tab-pane active" id="report">
    {% if perms.extras.run_report %}
      <div class="row">
        <div class="col">
          {% if not report.is_valid %}
            <div class="alert alert-warning">
              <i class="mdi mdi-alert"></i>
              {% trans "This report is invalid and cannot be run." %}
            </div>
          {% endif %}
          <form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post" class="form-object-edit">
            {% csrf_token %}
            {% render_form form %}
            <div class="float-end">
              <button type="submit" name="_run" class="btn btn-primary"{% if not report.is_valid %} disabled{% endif %}>
                {% if report.result %}
                  <i class="mdi mdi-replay"></i> {% trans "Run Again" %}
                {% else %}
                  <i class="mdi mdi-play"></i> {% trans "Run Report" %}
                {% endif %}
              </button>
            </div>
          </form>
        </div>
      </div>
    {% endif %}
    <div class="row">
      <div class="col col-md-12">
        {% if report.result %}
          {% trans "Last run" %}: <a href="{% url 'extras:report_result' job_pk=report.result.pk %}">
            <strong>{{ report.result.created|annotated_date }}</strong>
          </a>
        {% endif %}
      </div>
    </div>
  </div>
{% endblock content %}
